
import java.math.BigInteger;
import java.util.HashSet;
import java.util.Iterator;

public class e003 {
    public static void main(String[] args) {
		long sTime = System.currentTimeMillis();
        HashSet<Long> sieve = Sieve(1000000);
        BigInteger e = new BigInteger("600851475143");
        Iterator itr = sieve.iterator();
        long biggest = 0;
        while(itr.hasNext()) {
            BigInteger n = new BigInteger(String.valueOf(itr.next()));
            while (e.mod(n) == BigInteger.ZERO){
                e = e.divide(n);
                if (Long.parseLong(String.valueOf(n)) > biggest) {
                    biggest = Long.parseLong(String.valueOf(n));
                }
            }
        }
        System.out.println(biggest);
		long fTime = System.currentTimeMillis();
		System.out.println("Time: " + (fTime - sTime) + "ms");
    }

    public static HashSet<Long> Sieve(int limit) {
        HashSet<Long> allNums = new HashSet<Long>();
        for(long i = 2; i <= limit; i++) {
            allNums.add(i);
        }
        long p = 2;
        int numIndex = 1;
        boolean stop = false;
        while (!stop) {
            int size = allNums.size();
            for (long i = 2; i <= limit / p; i++) {
                long n = i * p;
                allNums.remove(n);
            }
            if (size == allNums.size() && allNums.contains(p)){
                stop = true;
            }
            p ++;
            numIndex++;
        }
        return allNums;
    }
}